package com.chen.manager.controller;


import com.chen.manager.service.FileUploadService;
import com.chen.model.vo.common.Result;
import com.chen.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author cgj
 * @date 2/19/25 7:59 PM
 */
@RestController
@RequestMapping("/admin/system")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;
    @PostMapping("/upload")
    //MultipartFile file 这个名字要和前端的name对应上. 我用的是element plus 默认的名字就是file
    public Result<String> fileUpload(MultipartFile file){
        //最后返回的是文件minio文件预览的浏览器的路径, 给前端作回显用
        // 见下面的我标红的图像
        String fileUrl=fileUploadService.fileUpload(file);
        return Result.build(fileUrl, ResultCodeEnum.SUCCESS);
    }
}
